﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using SH.Ms.JwtHelper;
using System.Data;
using System.Reflection;

namespace SH.Ms.JWTHelper.Demo.Controllers
{
    public class HomeController : Controller
    {
        private readonly JwtSettings _jwtSettings;


        public HomeController(JwtSettings jwtSettings)
        {
            _jwtSettings = jwtSettings;
        }
        public IActionResult Index()
        {
            UserTokens userTokens = new UserTokens
            {
                Id = "111",
                ExpiredTime = DateTime.Now.AddMinutes(40),
                UserName = "name",
                Roles = "Admin  ",
                EmailId = ""
            };
            //if (data.Cliams != null)
            //{
            //    foreach (var item in data.Cliams)
            //    {
            //        userTokens.ClaimsExt.Add(item.Name, item.Value);
            //    }
            //}
            userTokens = JwtHelpers.GenTokenkey(userTokens, _jwtSettings);

            return Json(userTokens);
        }
        [Authorize]
        public IActionResult Auth()
        {
            return Ok("Auth OK");
        }
    }
}
